//
//  ComonDataService.h
//  HZHome
//
//  Created by SunShine on 13-9-21.
//  Copyright (c) 2013年 xzysun. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "MKNetworkKit.h"
#import "InfoWithPhoneAndMapCell.h"
#import "CommonMineQueryItem.h"
#import "WorkQueryCell.h"
#import "StreetWorkEntity.h"
#import "CommonWorkGuideEntity.h"
#import "HMSegmentedControl.h"
#import "StreetWorkGuideEntity.h"

@protocol DataDelegateProtocol;
@interface CommonDataService : NSObject
{
    NSString *_dataItemName;
    int _currentPageNo;
    MKNetworkEngine *_currentEngine;
    void (^SuccessBlock)(id);//包含执行成功的回调
    void (^FailBlock)(NSError *);//包含执行失败的回调
}
@property (strong, nonatomic) NSArray *dataList;
//@property (strong, nonatomic) NSMutableArray *dataList;
@property (strong, nonatomic) id dataItem;
@property (weak, nonatomic) id<DataDelegateProtocol> delegate;
@property (assign, nonatomic) NSInteger fastSearchType;//标识快速搜索的类型
@property (nonatomic, strong) NSMutableDictionary *paramDic; //中转传递的参数集
/**
 *	@brief	开始载入数据
 *
 *	@param 	keyOrNil 	搜索时传入输入值，刷新时传入nil
 */
-(void)loadDataWithKey:(NSString *)keyOrNil;

/**
 *	@brief	载入更多数据
 *
 *	@param 	keyOrNil 	搜索时传入输入值，刷新时传入nil
 */
-(void)loadMoreDataWithKey:(NSString *)keyOrNil;

/**
 *	@brief	获取Segments的标题列表
 *
 *	@return	标题的列表
 */
-(NSArray *)getSegmentsTitles;
-(NSArray *)getSegmentsTitles:(int)index;

/**
 *	@brief	UISegmentedControl的值发生变化
 *
 *	@param 	selected 	被选中的index
 */
-(void)selectSegmentBarAtIndex:(NSInteger)selected;

/**
 *	@brief	配置一个cell
 *
 *	@param 	cell 	需要被配置的cell
 *	@param 	index 	cell的indexPath
 */
-(void)configCell:(UITableViewCell*)cell atIndex:(NSIndexPath*)index;

/**
 *	@brief	返回特定位置的cell所需要的高度
 *
 *	@param 	index 	cell的indexPath
 *
 *	@return	高度值
 */
-(CGFloat)heightForCellAtRow:(NSIndexPath*)index;

/**
 *	@brief	发起请求
 *
 *	@param 	posturl 	请求url
 *	@param 	headersOrNil 	自定义请求头，可以为nil
 *	@param 	path 	请求url需要追加的路径
 *	@param 	params 	post的body
 */
-(void)doHttpPost:(NSString *)posturl headers:(NSDictionary*)headersOrNil path:(NSString*)path parameters:(NSDictionary *)params;
-(void)doHttpPost:(NSString *)posturl  path:(NSString*)path parameters:(NSDictionary *)params;

/**
 *	@brief	发起请求
 *
 *	@param 	posturl 	请求url
 *	@param 	headersOrNil 	自定义请求头，可以为nil
 *	@param 	path 	请求url需要追加的路径
 *	@param 	params 	post的body
 */
-(void)doHttpGet:(NSString *)posturl headers:(NSDictionary*)headersOrNil path:(NSString*)path parameters:(NSDictionary *)params;

/**
 *	@brief	取消请求
 */
-(void)cancelAllRequest;

/**
 *	@brief	获取cell目标的配置信息
 *
 *	@param 	indexPath 	cell的indexPath
 *
 *	@return	配置信息字典
 */
-(NSDictionary *)getTargetConfigForCellAtIndex:(NSIndexPath*)indexPath;

//获取列表底部显示的消息
-(NSString *)getButtomTips;

-(ConfigableViewController *)getCellTargetViewControllerForName:(NSString *)className;


-(void)initDataItem:(NSString*)itemClassName withArray:(NSArray*)array;
- (void)initDataItem:(NSString*)itemClassName withDict:(NSDictionary*)dict;

//针对我要查询下面的页面的cell配置方法
-(void)configInfoWithPhoneAndMapCell:(InfoWithPhoneAndMapCell *)cell withItem:(CommonMineQueryItem *)item atIndex:(NSInteger)index;
-(void)configInfoWithGuidCell:(WorkQueryCell *)cell withItem:(StreetWorkEntity *)item atIndex:(NSInteger)index;
-(void)configInfoWithEnterpriseGuidCell:(WorkQueryCell *)cell withItem:(CommonWorkGuideEntity *)item atIndex:(NSInteger)index;
-(void)configInfoWithCommonGuidCell:(WorkQueryCell *)cell withItem:(StreetWorkGuideEntity *)item atIndex:(NSInteger)index;
@end

@protocol DataDelegateProtocol <NSObject>

-(void)loadDataFinished;
-(void)loadDataFaild:(NSString*)msg;
@optional
-(void)setEnableToLoadMore:(BOOL)enable;
//-(NSString *)httpGet:(NSString *)url;//get方式
//-(NSString *)httpPost:(NSString *)url;//post方式
@end
